package com.vcg;

import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline;
import io.reactivex.netty.RxNetty;
import io.reactivex.netty.channel.ConnectionHandler;
import io.reactivex.netty.channel.ObservableConnection;
import io.reactivex.netty.pipeline.PipelineConfigurator;
import io.reactivex.netty.server.RxServer;
import rx.Observable;

public class Server {
    public static void main(String[] args) {
        RxServer<Object, Object> rxServer = RxNetty.newTcpServerBuilder(3001, new ConnectionHandler<Object, Object>() {
            public Observable<Void> handle(ObservableConnection<Object, Object> newConnection) {
                return null;
            }
        })
                .pipelineConfigurator(new PipelineConfigurator<Object, Object>() {
                    public void configureNewPipeline(ChannelPipeline pipeline) {
                        pipeline.addLast(new SharedWashingMachineHeathDecode());
                        pipeline.addLast(new SharedWashingMachineHeathEncode());
                        pipeline.addLast(new ServerHandler());
                    }
                })
                .childChannelOption(ChannelOption.SO_KEEPALIVE, true)
                .build();
        rxServer.startAndWait();
    }
}
